package com.uls.web.controller.ycl;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uls.common.annotation.Log;
import com.uls.common.core.controller.BaseController;
import com.uls.common.core.domain.AjaxResult;
import com.uls.common.enums.BusinessType;
import com.uls.ycl.domain.NoticeReminder;
import com.uls.ycl.service.INoticeReminderService;
import com.uls.common.utils.poi.ExcelUtil;
import com.uls.common.core.page.TableDataInfo;

/**
 * 通知提醒Controller
 * 
 * @author ycl
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/ycl/reminder")
public class NoticeReminderController extends BaseController
{
    @Autowired
    private INoticeReminderService noticeReminderService;

    /**
     * 查询通知提醒列表
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:list')")
    @GetMapping("/list")
    public TableDataInfo list(NoticeReminder noticeReminder)
    {
        startPage();
        List<NoticeReminder> list = noticeReminderService.selectNoticeReminderList(noticeReminder);
        return getDataTable(list);
    }

    /**
     * 导出通知提醒列表
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:export')")
    @Log(title = "通知提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticeReminder noticeReminder)
    {
        List<NoticeReminder> list = noticeReminderService.selectNoticeReminderList(noticeReminder);
        ExcelUtil<NoticeReminder> util = new ExcelUtil<NoticeReminder>(NoticeReminder.class);
        util.exportExcel(response, list, "通知提醒数据");
    }

    /**
     * 获取通知提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(noticeReminderService.selectNoticeReminderById(id));
    }

    /**
     * 新增通知提醒
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:add')")
    @Log(title = "通知提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NoticeReminder noticeReminder)
    {
        noticeReminder.setCreateBy(getUsername());
        noticeReminder.setCreateTime(new Date());
        return toAjax(noticeReminderService.insertNoticeReminder(noticeReminder));
    }

    /**
     * 修改通知提醒
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:edit')")
    @Log(title = "通知提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NoticeReminder noticeReminder)
    {
        noticeReminder.setUpdateBy(getUsername());
        return toAjax(noticeReminderService.updateNoticeReminder(noticeReminder));
    }

    /**
     * 删除通知提醒
     */
    @PreAuthorize("@ss.hasPermi('ycl:reminder:remove')")
    @Log(title = "通知提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(noticeReminderService.deleteNoticeReminderByIds(ids));
    }
}
